﻿using System;
using UnityEngine;

namespace SYFranework
{ 
    public abstract class Singelon<T> where T :class ,new()
    {
        private static T _instance = null;
        public static T Instance
        {
            get
            {
                if (null == _instance)
                {
                    _instance = new T();
                }
                return _instance;
            }
        }

        protected Singelon()
        {
            if (null != _instance)
            {
                throw new SingelonException("this" + (typeof(T).ToString() + "单例不为空"));
            }
            // 进行初始化操作
            Init();
        }
        // 初始化工作
        public virtual void Init()
        {
            Debug.Log("Singelon init");
        }

    }
}
